package 笔试.皇甫;

import 笔试.乐金祥.Main;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/9/1-19:06
 * @version:1.0
 * @function:
 */
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int i = 0, j = 0, count = 0;
        int[] arr = new int[n];
        while (true) {
            if (arr[i] == 0) {
                j++;
                if (j % 3 == 0) {
                    arr[i] = 1;
                    count++;
                }
                if (count == n - 1) {
                    break;
                }
            }
            i = (i + 1) % n;
        }
        j=0;
        for (; j < arr.length; j++) {
            if (arr[j]==0)break;
        }
        System.out.println(j+1);
    }
}
